<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="lushu">
		<title>备用金帐户充值</title>
		<script language="javascript" type="text/javascript" src="../script/print.js"></script>
		<script language="javascript" src="../script/common.js" type="text/javascript"></script>
		<script language="javascript" src="../script/card.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript">
			var Page;
			var data
			function initPageElements(){
				Page.readonlyTableStyle = "col2 label8";
				Page.initOperationForm = function(result){
					var type = result.cardUser.type;
					if (type==CardUserType.NAME && !result.customer){
						showWarning("不记名卡不能进行备用金充值操作");
						return false;
					}
					Common.initDict(Page.operationForm.payType,Common.getSubsetItems("pay_type",TX.PAYMENT_TYPE));
					Common.initDict(Page.operationForm.accCode,TX.AccountType.deposit());
					changePayment(Page.operationForm.payType);
					return true;
				}
				Page.bill = "trade_in_bill";
				Page.preResult = function(result){
					showInformation("充值成功");
				}
//				Page.postResult = function(){
//					if(Page.userInfo.cardUser.invoiceType == InvoiceType.DEPOSIT)
//						TX.Invoice.saveInvoice(Page.userInfo.cardUser.uniqueId
//											 , 0
//											 , Page.amountInSystem(data.amount)
//											 );
//				}
			}
			//更改支付方式
			function changePayment(obj){
				var payType;
				if (obj)
					payType = obj.value;
				var extraInput = "";
				if(payType==Constants.PAYMENT_BANK){
					extraInput =  $("bankPaymentDiv").innerHTML;
				}
				$("payTypeArea").innerHTML = extraInput;
			}

			function doDeposit(){
				if(!checkForm(operationForm))
					return;
				data = Common.getValues(Page.operationForm);
				var confirmString =   "客户编号:" + data.cardUserUnique + TX.SHOW_INFO_LINEBREAK 
									+ "充值帐户:" + Common.getText('account_type',data.accCode) + TX.SHOW_INFO_LINEBREAK
									+ "帐户单位:" + data.unit + TX.SHOW_INFO_LINEBREAK
									+ "充 值 额:" + data.amount + TX.SHOW_INFO_LINEBREAK
									+ "充值类型:" + Common.getText("pay_type",data.payType);
				if(data.bankCard){
					confirmString += TX.SHOW_INFO_LINEBREAK+"银行卡卡号:"+data.bankCard
									+TX.SHOW_INFO_LINEBREAK+"银行卡交易流水号:"+data.bankTrace;
					data.bankTrade = {};
					data.bankTrade.acquirerUniqueId = data.acquirerUniqueId;
					data.bankTrade.bankCard = data.bankCard;
					data.bankTrade.bankTrace = data.bankTrace;
				}
				if(showQuestion(confirmString)){
					DWR.call("tradeService.counterDeposit",
							data.cardUserUnique,
							Page.amountInSystem(data.amount),
							data.accCode,
							data.payType,
							TX.DEFAULT_CURRENCY,
							data.bankTrade,
							data.chequeId,
							TX.Trade.showResult,
							{disCtrl:Page.operationForm.operation}
						);
				}else{
					Page.operationForm.amount.value="";
					Page.operationForm.amount.focus();
				}
			}
			
		</script>
	</head>
	<body onload="TX.NoCardTrade.init()">
		<div class="nav"><div id="nav">&nbsp;</div></div>
		<div id="searchFormDiv">
			<div class="form">
				<div class="formTitle">请输入要充值帐户的相关信息</div>	
				<form id="searchForm" name="searchForm">
					<input type="hidden" name="asn">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" align="center">
						<tr>
							<td>
								<label>客户编号</label> 
								<input type="text" size="22" name="cardUserUnique" value="" maxlength="18" onblur="checkV(this,'uniqueId',true)">
							</td>
							<td><button name="search" onclick="TX.NoCardTrade.getUserAccountInfo()">查  询</button></td>
						</tr>
					</table>
				</form>	
			</div>
		</div>
		
		<div id="operationFormDiv" style="display:none;">
			<div class="form">
				<div class="formTitle">备用金帐户充值</div>	
				<form id="operationForm" name="operationForm">
					<span id="readonlyInfo"></span>
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="col2 label8">
						<tr>
							<td><label>帐户类型</label> <select name="accCode" onchange="TX.NoCardTrade.changeAccCode(this)"><option></option></select></td>
							<td><label>充 值 额</label> <input type="text" name="amount" onblur="Page.amountValidator(this)"><span class="des">*</span></td>
						</tr>
						<tr>
							<td><label>支付方式</label> <select name="payType" onchange="changePayment(this)"><option></option></select></td>
							<td></td>
						</tr>
					</table>
					<div id="payTypeArea"></div>
					<p>
						<button id="operation" onclick="doDeposit()">充 值</button>
						<button onclick="TX.NoCardTrade.goFirstPage()">返 回</button>
					</p>
				</form>
			</div>
			<div style="display:none;" id="bankPaymentDiv">
				<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="col2 label8">
					<tr>
						<!--
						<td><label>银行卡所属机构</label> <input type='text' name='acquirerUniqueId' value='9001' readonly onblur="checkV(this,'long',true)"><span class="des">*</span></td>
						-->
						<td><label>银行卡卡号</label> <input type='text' name='bankCard' value='' onblur="checkV(this,'bankCard',true)"><span class="des">*</span></td>
						<td><label>银行卡交易流水号</label> <input type='text' name='bankTrace' value='' onblur="checkV(this,'long',true)"><span class="des">*</span></td>
					</tr>
				</table>
			</div>
		</div>
			
		<div id="printSheetDiv" style="display:none;" >
			<div class="form">
				<div class="formTitle">充值明细</div>
				<div id="mainTrade"></div>
			</div>
			<p>
				<button onclick="TX.NoCardTrade.goFirstPage()">返 回</button>
			</p>
		</div>
		<div id="billDiv" class="form" style="display:none;">
			<div class="formTitle">
				<div class="l">交易凭证</div>
				<div class="r">
					<button onclick="WebPrint.preview('content')">打印预览</button>
			 		<button onclick="WebPrint.print('content')">打印</button>
			 		<button onclick="TX.NoCardTrade.goFirstPage()">返 回</button>
				</div>
			</div>
			<div id="content" align='center'></div>
		</div>
	</body>
</html>